﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;
using KPIS.GERP.GIMS.DAL;
using KPIS.GERP.GIMS.MODEL;
using KPIS.GERP.GIMS.IBLL;
using KPIS.GERP.GIMS.BLL;

namespace KPIS.GERP.GIMS.APP.APP_UI.Form
{
    public partial class ICM_Asset_Register : System.Web.UI.Page
    {
        IBLLSysYearType bllYearType = new SysYearTypeBLL();
        SysControlBLL bllSysCon = new SysControlBLL();        
        D_Asset d_asset = new D_Asset();
        M_Asset m_asset = new M_Asset();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadYearType();
                LoadDefault();
                LoadGrid();
                grdAsset.DataBind();
            }
        }
        protected void LoadDefault()
        {
            SysControlInfo infoDefault = bllSysCon.GetDefaultData();
            if (infoDefault.YearType != null)
            {
                cbYearType.SelectedValue = infoDefault.YearType.ToString();
                Session["yearSeq"] = cbYearType.SelectedValue;
                Session["yearSeq_Urgent"] = cbYearType.SelectedValue;

            }
            if (infoDefault.Year != null)
            {
                txtYear.Text = infoDefault.Year.ToString();
                Session["year"] = txtYear.Text;
                Session["year_Urgent"] = txtYear.Text;
            }
        }
        protected void LoadYearType()
        {
            IList<SysYearTypeInfo> infoList = bllYearType.GetSysYearType();
            cbYearType.DataSource = infoList;
            cbYearType.DataBind();
        }
        protected void grdAsset_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            LoadGrid();
        }
        private void LoadGrid()
        {
            grdAsset.DataSource = d_asset.GetList() ;
        }
        protected void btnInsert_Click(object sender, EventArgs e)
        {
        }
        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            LoadGrid();
            grdAsset.Rebind();
        }
        protected void OnAjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            //RadAjaxPanel1.Controls.Add(Page.LoadControl("../UserControl/Personal_Data.ascx"));
        }
        protected void btnShow_Click(object sender, EventArgs e)
        {
            Session["yearSeq"] = cbYearType.SelectedValue;
            Session["year"] = txtYear.Text;
            LoadGrid();
        }
    }
}
